package com.sbhotel.chotellauncher.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sbhotel.chotellauncher.R;

import java.util.List;

public class SleepTurnOffAdapter extends BaseAdapter {

    List<String> list;
    Context mContext;

    public SleepTurnOffAdapter(Context context, List<String> data) {
        list = data;
        mContext = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int position, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if(view == null) {
            view = LayoutInflater.from(mContext).inflate(R.layout.item_sleep, null);
            holder = new ViewHolder(view);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
            holder.tv.setText(list.get(position));
            Log.d("showboom", "list.get(position) = " + list.get(position));
        }
        return view;
    }

    class ViewHolder{
        TextView tv;

        public ViewHolder(View view) {
            tv = view.findViewById(R.id.tv_sleep_value);
        }
    }
}
